package com.it.reggie.controller;

import com.it.reggie.Exception.BusinessException;
import com.it.reggie.Exception.SystemException;
import com.it.reggie.commen.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


@Slf4j
@RestControllerAdvice//配置全局异常处理器
public class ProjectExceptionAdvice {


    @ExceptionHandler(Exception.class)
    public R doException(Exception e) {

        log.info("异常信息"+e);
        return R.error(e.getMessage());

    }

    @ExceptionHandler(BusinessException.class)//具体异常类信息
    public R businessException(BusinessException e){
        log.info("异常信息"+e);
        return R.error(e.getMessage());
    }

    @ExceptionHandler(SystemException.class)
    public R systemException(SystemException e){
        log.info("异常信息"+e);
        return R.error(e.getMessage());
    }
}
